package learn_0324;


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class hui_su {

    List<List<Integer>> res = new LinkedList<>();

    List<List<Integer>> meiju(int[] nums){
        LinkedList<Integer> track  = new LinkedList<>();
        backtrack(nums,track);
        return res;
    }

    void backtrack(int[] nums,LinkedList<Integer> track){
        if (track.size() == nums.length){
            res.add(new LinkedList<>(track));
            return;
        }
        for(int i=0;i<nums.length;i++){
            if(track.contains(nums[i])){
                continue;
            }
            track.add(nums[i]);
            backtrack(nums,track);
            track.removeLast();
        }
    }

    public static void main(String[] args) {
        hui_su huiSu = new hui_su();

        int[] nums = {1,2,3};
        List<List<Integer>> result = huiSu.meiju(nums);
        System.out.print(result);
    }


 }
